/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SecureDelete.Table;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Diego Catalano
 */
public class FileDescriptionModel extends AbstractTableModel {
 
    private final int COL_PATH = 0;
 
    private List<FileDescription> files;
 
    public FileDescriptionModel() {
        files = new ArrayList();
    }
 
    public FileDescriptionModel(List<FileDescription> list) {
        this();
        files.addAll(list);
    }
 
    public int getRowCount() {
        return files.size();
    }
 
    public int getColumnCount() {
        return 1;
    }
 
    @Override
    public String getColumnName(int column) {
        if (column == COL_PATH) {
            return "Path";
        }
        return "";
    }
 
    @Override
    public Class getColumnClass(int columnIndex) {
        if (columnIndex == COL_PATH) {
            return String.class;
        }
        return String.class;
    }
 
    public Object getValueAt(int rowIndex, int columnIndex) {
        FileDescription p = files.get(rowIndex);
 
        if (columnIndex == COL_PATH) {
            return p.getPathname();
        }
        return "";
    }
 
    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        FileDescription p = files.get(rowIndex);
 
        if (columnIndex == COL_PATH) {
            p.setPathname(aValue.toString());
        }
 
        fireTableDataChanged();
    }
 
    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }
}